<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="author" content="得闲技术 Team">
    <meta name="copyright" content="得闲技术">
    <title>修改密码 - Powered By 得闲技术</title>
    [#include "/admin/main/resources/list.ftl"/]
</head>
<body class="admin secondary">
<main>
    <div class="container-fluid">
        <form id="saveOrUpdateForm" class="ajax-form form-horizontal" action="modify_password" method="post">
            <div class="panel panel-default">
                <div class="panel-heading">修改密码</div>
                <div class="panel-body padding-5">
                    <div class="tab-content">
                        <div id="basic" class="tab-pane active">

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required"
                                        for="oldPassword">原密码:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="oldPassword" name="oldPassword" class="form-control" type="password"
                                            minlength="6" maxlength="60"
                                            required="required" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="password">新密码:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="newPassword" name="newPassword" class="form-control" type="password"
                                            minlength="6" maxlength="60"
                                            required="required" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required"
                                        for="password">确认密码:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="rePassword" name="rePassword" class="form-control" type="password"
                                            minlength="6" maxlength="60" required="required" />
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-xs-9 col-sm-10 col-xs-offset-3 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit">确 定</button>
                            <button class="btn btn-default" type="button" data-action="back">返 回</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</main>
<script>
    $().ready(function () {

        var $saveOrUpdateForm = $("#saveOrUpdateForm");

        // 表单验证
        $saveOrUpdateForm.validate({
            rules: {
                oldPassword: {
                    remote: {
                        url: "check_old_password",
                        cache: false
                    }
                },
                rePassword: {
                    equalTo: "#newPassword"
                },
            },
            messages: {
                oldPassword: {
                    remote: "原密码不正确"
                }
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    successRedirectUrl: "modify_password"
                });
            }
        });
    });
</script>
</body>
</html>
